export default {
  set: function (name, value, expires, domain, path, secure) {
    let cookieText = encodeURIComponent(name) + '=' + value

    if (expires instanceof Date) {
      cookieText += '; expires=' + expires.toGMTString()
    }

    if (path) {
      cookieText += '; path=' + path
    } else {
      cookieText += '; path=/'
    }

    if (domain) {
      cookieText += '; domain=' + domain
    }

    if (secure) {
      cookieText += '; secure'
    }
    document.cookie = cookieText
  },

  unset: function (name, domain, path, secure) {
    this.set(name, '', new Date(0).toUTCString(), domain, path, secure)
  }
}
